/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.form;

import org.rails.extjs.Option;

public class TextArea extends TextField {

	public TextArea() {
		super();
	}

	public TextArea(Option configOptions) {
		super(configOptions);
	}
	
	public TextArea(String name) {
		super(name);
	}

	public TextArea(String name,String fieldLabel) {
		super(name,fieldLabel);
	}

	public TextArea(String name,String fieldLabel, Object value) {
		super(name,fieldLabel,value);
	}
	
	@Override
	public Tag getAutoCreate(){
		Tag ac = new Tag();
		ac.setTag("textarea");
		ac.setStyle("width:100px;height:60px;");
		ac.setAutocomplete("off");
		return getOption("autoCreate") == null ? ac : (Tag)getOption("autoCreate");
	}
	
	public void setGrowMax(Integer growMax){
		addOption("growMax", growMax);
	}
	
	public Integer getGrowMax(){
		return getInteger("growMax", 1000);
	}
	
	public void setGrowMin(Integer growMin){
		addOption("growMin", growMin);
	}
	
	public Integer getGrowMin(Number growMin){
		return getInteger("growMin", 60);
	}
	
	public void setPreventScrollbars(Boolean preventScrollbars){
		addOption("preventScrollbars",preventScrollbars);
	}
	
	public Boolean isPreventScrollbars(){
		return getBoolean("preventScrollbars",false);
	}
	
	@Override
	public String getScript() {
		script = new StringBuffer("");
		createItems();
		script.append("new Ext.form.TextArea(");
		script.append(createOptions());
		script.append(")");
		return script.toString();
	}

}
